package com.woniuxy.location.service.impl;

import com.woniuxy.location.service.LocationService;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
@Service
public class LocationServiceImpl implements LocationService {
    @Resource
    private StringRedisTemplate stringRedisTemplate;
    @Override
    public Point getAttendantLocation(int aid) {
        Point location = stringRedisTemplate.opsForGeo().position("location", "attendant:" + aid).get(0);
        return location;
    }

    @Override
    public Distance getDistance(int did, int aid) {
        Distance distance = stringRedisTemplate.opsForGeo().distance("location", "attendant:" + aid, "disabled:" + did);
        return distance;
    }
}
